#include "myhead.h"

void other(void *arg)
{
	printf("当线程被干掉的时候，我会自动被调用，线程不被干掉的时候，我一点作用都没有!\n");
}


void *fun(void *arg)
{
	pthread_cleanup_push(other,NULL); 
    printf("线程运行得很正常!\n");
	//pthread_cleanup_pop(0); //不执行other
	pthread_cleanup_pop(1);  //执行other
}
int main()
{

	pthread_t id;
	pthread_create(&id,NULL,fun,NULL);
	pthread_join(id,NULL);

}